package net.obxlabs.tweetpad.test;

import java.awt.Font;

import net.nexttext.Book;
import net.nexttext.behaviour.*;
import net.nexttext.behaviour.standard.*;
import net.nexttext.behaviour.control.*;
import net.nexttext.behaviour.dform.Pull;
import net.nexttext.behaviour.dform.Reform;
import net.nexttext.behaviour.physics.*;
import net.nexttext.processing.ProcessingMouse;
import net.obxlabs.tweetpad.behaviour.*;
import net.silentlycrashing.gestures.*;
import processing.core.*;

public class T8NextTextGestures extends PApplet {
	GestureAnalyzer brain;
	ConcurrentGestureListener shaker;
	
	Book book;
    Font font;
    
	public void setup() {
        size(800, 600);
        frameRate(60);
        smooth();
        background(0);
        stroke(255, 0, 0);
        noFill();
        
        brain = new MouseGestureAnalyzer(this);
        shaker = new ConcurrentGestureListener(this, brain, "L?(RL){6,}R?");
        
        book = new Book(this);
        // load and set the font
        font = book.loadFont("bluehigh.ttf");
        book.textFont(font, 48);
        // pull the text with the first mouse button
  	  	Action pull = new Pull(Book.mouse, 10, 2);
	  	Action reform = new Reform();
		OnConcurrentGesture onGesture = new OnConcurrentGesture(shaker, pull, reform);
		book.addGroupBehaviour(onGesture.makeBehaviour());
		
		fill(255);
		book.addText("ca va, gros tas?", 50, 50);
		
		shaker.setBounds(book.getTextRoot().getBounds());
    }

    public void draw() {
    	background(0);
        book.stepAndDraw();
    }
}
